package com.example.github.jdbc;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class PrepareStatementJDBC {
    public static void main(String[] args) {
        String url = "jdbc:mysql://127.0.0.1:3306/mall";
        String username = "root";
        String password = "123456";
        try {
            // 获取连接
            Connection con = DriverManager.getConnection(url, username, password);
            // 执行预编译 sql
            CallableStatement callableStatement = con.prepareCall("select * from ums_role");
            boolean execute = callableStatement.execute();
            System.out.println(execute);
            // 从内到外关闭连接
            callableStatement.close();
            con.close();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
